
function EditUtil(context,action){
	this.context = context;
	this.action = context + action;
}

EditUtil.prototype = {
	/**
	 * 保存并新增
	 */
	doSaveAndAdd:function(){
		var form = document.forms[0];
		form.action = this.action + "?action=doSave&flag=doSaveAndAdd";
		form.submit();
	},
	/**
	 * 保存后返回
	 */
	doSaveAndExit:function(){
		var form = document.forms[0];
		form.action = this.action + "?action=doSave&flag=doSaveAndExit";
		form.submit();
	},
	/**
	 * 返回
	 */
	doReturn:function(){
		window.close();
	},
	/**
	 * 限制文本域的输入字数
	 * @param {Object} textObj 文本域的对象
	 * @param {String} spanId
	 * @param {int} maxLen 最大长度
	 */
	checkTextAreaValueLen:function(textObj, spanId, maxLen){
		var span = document.getElementById(spanId);
		if(span == null) return false;
		span.innerHTML =  parseInt(maxLen) - textObj.value.length;
		if(parseInt(span.innerHTML) <= 0 ){
			textObj.value = textObj.value.substring(0,maxLen);
			span.innerHTML = "0";
		}
	},
	/**
	 * 初始化文本域还能输入的字数
	 * @param {Object} textId 文本域的对象id
	 * @param {String} spanId
	 * @param {int} maxLen 最大长度
	 */
	loadCheckTextAreaValueLen:function(textId, spanId, maxLen){  
		var spanObj = document.getElementById(spanId);
		var textObj = document.getElementById(textId);   
		if(textObj==null || textObj=='undefined'){
			textObj = document.getElementsByName(textId)[0];
		}
		var result = maxLen-textObj.value.length;
		spanObj.innerHTML = result;		
	}
}